<template>
    <div class="z-date-radio">
        <div
            class="z-date-radio__item"
            :class="{ 'z-date-radio__item--active': index === active }"
            v-for="(item, index) in options"
            :key="index"
            @click="change(index)"
        >
            {{ item }}
        </div>
    </div>
</template>

<script>
export default {
    name: "z-date-radio",
    data() {
        return {
            options: ["周", "月", "年"],
            active: 0
        };
    },
    methods: {
        change(index) {
            this.active = index;
            this.$emit("change", this.active);
        }
    }
};
</script>

<style>
.z-date-radio {
    display: flex;
    align-items: center;
    background: rgba(19, 33, 60, 0);
    border: 1px solid #20bcfc;
}

.z-date-radio__item {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 6rem;
    height: 2.8rem;
    font-size: 1.6rem;
    color: #23cefd;
    opacity: 0.5;
    cursor: pointer;
    transition: all 0.3s;
}

.z-date-radio__item--active {
    box-shadow: inset 0 0 1rem #20bcfc;
    opacity: 1;
}
</style>